package com.unlcn.ils.kas.async;

import java.util.List;
import java.util.concurrent.CountDownLatch;

import com.unlcn.ils.kas.dao.model.erp.VJmcKasFlowInfo;
import com.unlcn.ils.kas.service.order.SharesOrderService;

import org.apache.log4j.Logger;

public class DealMiddleRunnable implements Runnable {
  private final static Logger logger = Logger.getLogger(DealMiddleRunnable.class);

  private final CountDownLatch countDown;

  private final List<VJmcKasFlowInfo> lst;

  private final SharesOrderService service;

  public DealMiddleRunnable(CountDownLatch countDown, List<VJmcKasFlowInfo> lst, SharesOrderService service) {
    this.countDown = countDown;
    this.lst = lst;
    this.service = service;
  }

  @Override
  public void run() {
    try {
      if (null != lst && !lst.isEmpty()) {
        service.dealMiddle(lst);
      }
    } catch (Exception e) {
      String threadName = Thread.currentThread().getName();
      logger.error("DealMiddleRunnable.run [" + threadName + "]...", e);
    } finally {
      countDown.countDown();
    }
  }

}
